// +----------------------------------------------------------------------
// | Author: dw <827400818@qq.com>
// +----------------------------------------------------------------------
$(function(){
    layui.use(['layer'], function () {
        var layer = layui.layer;
        $(".to-view").mouseover(function () {
            var dw_url = $(this).attr("dw-url");
            var id     = $(this).attr("id");
            $.post(dw_url, {}, function (obj) {
                var content = '';
                var count   = obj.data.length;
                $.each(obj.data, function (index, item) {
                    console.log(item);
                    content += '<span class="layui-badge layui-bg-green" style="margin: 5px;">' + item + "</span>";
                });
                //根据数量采用不同的方式显示
                if (count <= 10) {
                    layer.tips(content, "#" + id, {
                        tips: [2, '#000000'],
                        time: 0
                    });
                } else {
                    layer.open({
                        title: '角色-用户明细',
                        type: 1,
                        closeBtn: false,
                        shadeClose: true,
                        skin: 'layui-layer-dw-blank', //使用自定义皮肤
                        area: ['420px', '320px'], //宽高
                        content: content
                    });
                }
            });

        });
    });
})
